package com.regent.central.bill.repository;

import com.regent.central.bill.core.CreateGoods;
import com.regent.central.bill.dto.sale_order.SaleOrderDetailCreateGoodsDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface CreateGoodsMapper extends Mapper<CreateGoods> {

    /**
     * 获取指定销售单的开单总额
     *
     * @param saleOrderId 销售单ID
     * @return 该销售单的开单总额
     */
    BigDecimal getCreateGoodsAmount(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 获取指定销售单的总开单数量
     *
     * @param saleOrderId 销售单ID
     * @return 该销售单的总开单数量
     */
    BigDecimal getCreateGoodsTotal(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 获取销售单详情开单货品列表
     *
     * @param saleOrderId 销售单ID
     * @return 销售单详情开单货品列表
     */
    List<SaleOrderDetailCreateGoodsDTO> getSaleOrderDetailCreateGoods(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 删除开单货品
     *
     * @param createGoodsId 开单货品ID
     * @param userDeleted   删除人
     * @param timeDeleted   删除时间
     */
    void hide(
            @Param("createGoodsId") String createGoodsId,
            @Param("userDeleted") String userDeleted,
            @Param("timeDeleted") long timeDeleted
    );

    /**
     * 根据开单动作ID删除开单货品
     *
     * @param createActionId 开单动作ID
     * @param userDeleted    删除人
     */
    void deleteForSaleOrderCreateAction(
            @Param("createActionId") String createActionId,
            @Param("userDeleted") String userDeleted,
            @Param("timeDeleted") long timeDeleted
    );

    /**
     * /**
     * 获取销售单的开单要货
     *
     * @param saleOrderId 销售单ID
     * @param canceled    已撤销
     * @param deleted     已删除
     * @return 销售单的开单要货
     */
    List<CreateGoods> getSaleOrderCreateGoods(
            @Param("saleOrderId") String saleOrderId,
            @Param("canceled") Boolean canceled,
            @Param("deleted") Boolean deleted
    );

    /**
     * 获取某个销售单的指定style开单要货货品
     *
     * @param saleOrderId 销售单ID
     * @param styleId     款号ID
     * @return 某个销售单的指定style开单要货货品
     */
    CreateGoods getSaleOrderCreateGoodsOfStyle(
            @Param("saleOrderId") String saleOrderId,
            @Param("styleId") String styleId
    );

}